package com.hy.controller;

import javax.validation.Valid;

import org.hibernate.validator.constraints.NotBlank;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.hy.base.ApiResult;
import com.hy.form.input.AreaAddForm;
import com.hy.service.IAreaService;

@RestController
@RequestMapping("/area")
@Validated
public class AreaController {

	@Autowired
	IAreaService areaService;
	
	/**
	 * 新增/修改区域信息
	 * 
	 * @param areaAddForm
	 * @return
	 */
	@RequestMapping("/add")
    public ApiResult add(@Valid @RequestBody AreaAddForm areaAddForm) {
		areaService.add(areaAddForm);
		return ApiResult.SUCCESS();
	}
	
	/**
     * 删除区域信息
     *
     * @param guid
     */
    @RequestMapping("/del")
    public ApiResult del(@NotBlank(message = "guid不能为空！") String guid){
    	areaService.del(guid);
        return ApiResult.SUCCESS();
    }
    
    /**
     * 根据条件查询区域信息
     *
     * @param guid
     * @return
     */
    @RequestMapping("/info")
    public ApiResult info(@NotBlank(message = "guid不能为空！") String guid){
        return ApiResult.SUCCESS(areaService.info(guid));
    }
    
    /**
     * 查询所有区域信息（list结构）
     *
     */
    @RequestMapping("/list")
    public ApiResult list(){
        return ApiResult.SUCCESS(areaService.list());
    }
   
}
